package lab03.test08;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        String file1 = "";
        String file2 = "";
        String file3 = "";
        FileInputStream file1InputStream = null;
        FileInputStream file2InputStream1 = null;
        FileOutputStream file3OutputStream = null;

        try {
            file1InputStream = new FileInputStream(file1);
            file2InputStream1 = new FileInputStream(file2);
            file3OutputStream = new FileOutputStream(file3);
            int data1;
            int data2 = 0;

            try {
                while (((data1= file1InputStream.read())!=-1) ||
                        ((data2= file2InputStream1.read())!=-1)
                        ){
                    file3OutputStream.write(data1);
                    file3OutputStream.write(data2);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            try {
                file1InputStream.close();
                file2InputStream1.close();
                file3OutputStream.close();

            } catch (IOException e) {
                e.printStackTrace();
            }

        }


    }
}